package hu.monitor.remoting.transport;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class SerializeMarshaller implements Marshaller {

	@Override
	public Object unmarshall(final InputStream input) throws IOException, ClassNotFoundException {
		final ObjectInputStream in = new ObjectInputStream(input);
		return in.readObject();
	}

	@Override
	public void marshall(final Object object, final OutputStream output) throws IOException {
		final ObjectOutputStream out = new ObjectOutputStream(output);
		try {
			out.writeObject(object);
			out.flush();
		} finally {
			out.reset();
		}

	}

}
